#-*- encoding:utf-8 -*-

'''
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.

This is case sensitive, for example "Aa" is not considered a palindrome here.

Note:
Assume the length of given string will not exceed 1,010.

Input:
"abccccdd"

Output:
7

Explanation:
One longest palindrome that can be built is "dccaccd", whose length is 7.
1 hash，存储，对字符数为偶数，字符数为奇数，取-1，再任取1
'''
from collections import Counter

class Solution(object):
    def longestPalindrome(self, s):
    	sHash = Counter(s)
    	res = 0
    	flag = 0
    	for k in sHash:
    		if sHash[k] == 1:
    			flag = 1
    		elif sHash[k]%2 ==0:
    			res += sHash[k]
    		else:
    			res += sHash[k]-1
    			flag = 1
    	res = res+flag
    	if res == 1:
    		return 0
    	return res

s='Aa'
ob = Solution()
print ob.longestPalindrome(s)
